/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.entities;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Issam
 */
@Entity
@Table(name = "ORDRE_ACHAT", catalog = "", schema = "NETTRADING")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrdreAchat.findAll", query = "SELECT o FROM OrdreAchat o"),
    @NamedQuery(name = "OrdreAchat.findByNumAchat", query = "SELECT o FROM OrdreAchat o WHERE o.numAchat = :numAchat"),
    @NamedQuery(name = "OrdreAchat.findByDateOrdre", query = "SELECT o FROM OrdreAchat o WHERE o.dateOrdre = :dateOrdre"),
    @NamedQuery(name = "OrdreAchat.findByDateExecution", query = "SELECT o FROM OrdreAchat o WHERE o.dateExecution = :dateExecution"),
    @NamedQuery(name = "OrdreAchat.findByNombreAction", query = "SELECT o FROM OrdreAchat o WHERE o.nombreAction = :nombreAction")})
public class OrdreAchat implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "NUM_ACHAT", nullable = false)
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Long numAchat;
    @Basic(optional = false)
    @Column(name = "DATE_ORDRE", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOrdre;
    @Basic(optional = false)
    @Lob
    @Column(name = "STATUT", nullable = false)
    private byte[] statut;
    @Column(name = "DATE_EXECUTION")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateExecution;
    @Basic(optional = false)
    @Column(name = "NOMBRE_ACTION", nullable = false)
    private BigInteger nombreAction;
    @ManyToMany(mappedBy = "ordreAchatCollection")
    private Collection<Action> actionCollection;
    @JoinColumn(name = "EMAIL", referencedColumnName = "EMAIL", nullable = false)
    @ManyToOne(optional = false)
    private Client email;

    public OrdreAchat() {
    }

    public OrdreAchat(Long numAchat) {
        this.numAchat = numAchat;
    }

    public OrdreAchat(Long numAchat, Date dateOrdre, byte[] statut, BigInteger nombreAction) {
        this.numAchat = numAchat;
        this.dateOrdre = dateOrdre;
        this.statut = statut;
        this.nombreAction = nombreAction;
    }

    public Long getNumAchat() {
        return numAchat;
    }

    public void setNumAchat(Long numAchat) {
        this.numAchat = numAchat;
    }

    public Date getDateOrdre() {
        return dateOrdre;
    }

    public void setDateOrdre(Date dateOrdre) {
        this.dateOrdre = dateOrdre;
    }

    public byte[] getStatut() {
        return statut;
    }

    public void setStatut(byte[] statut) {
        this.statut = statut;
    }

    public Date getDateExecution() {
        return dateExecution;
    }

    public void setDateExecution(Date dateExecution) {
        this.dateExecution = dateExecution;
    }

    public BigInteger getNombreAction() {
        return nombreAction;
    }

    public void setNombreAction(BigInteger nombreAction) {
        this.nombreAction = nombreAction;
    }

    @XmlTransient
    public Collection<Action> getActionCollection() {
        return actionCollection;
    }

    public void setActionCollection(Collection<Action> actionCollection) {
        this.actionCollection = actionCollection;
    }

    public Client getEmail() {
        return email;
    }

    public void setEmail(Client email) {
        this.email = email;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (numAchat != null ? numAchat.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdreAchat)) {
            return false;
        }
        OrdreAchat other = (OrdreAchat) object;
        if ((this.numAchat == null && other.numAchat != null) || (this.numAchat != null && !this.numAchat.equals(other.numAchat))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.entities.OrdreAchat[ numAchat=" + numAchat + " ]";
    }
    
}
